<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/10/2
  Time: 18:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script src="js/jquery-1.8.3.js"></script>
<html>
<head>
    <title>修改电池信息页面</title>
    <style>
        #box{
            margin: 0 auto;
            width: 1000px;
        }

    </style>
</head>
<body>
<form action="insert">
<div id="box">
    <table id="table" border="1px solid black">
        <tr>
            <input id="id" name="id" value="${sessionScope.power.id}" style="display: none">
            <td>车辆类型:</td>
            <td><input type="text" id="name" name="name" value="${sessionScope.power.carName}"></td>
        </tr>
        <tr>
            <td>所属城市:</td>
            <td><input type="text" id="city" name="city" value="${power.cityName}"></td>
        </tr>
        <tr>
            <td>使用单位:</td>
            <td><input type="text" id="user" name="user" value="${power.userName}"></td>
        </tr>
        <tr>
            <td>压差报警值:</td>
            <td><input type="text" id="values" name="values"value="${power.pressureValue}"></td>
        </tr>
        <tr>
            <td>报警时间:</td>
            <td><input type="text" id="time" name="time"value="${power.time}"></td>
        </tr>
        <tr>
            <td>操作:</td>
            <td><input type="button" value="操作" onclick="insert()"></td>
        </tr>
    </table>
</div>
</form>
</body>
<script>
    function insert(){
        var timi = /^\d{4}-\d{2}-\d{2}$/
        if ($("#name").val().trim()==""){
            alert("车辆型号不能为空")
            return false;
        }else if ($("#city").val().trim()==""){
            alert("城市不能为空!")
            return false;
        }else if ($("#user").val().trim()==""){
            alert("使用单位不能为空!!")
            return false
        }else if ($("#values").val().trim()==""){
            alert("请填写完整信息")
            return false;
        }else if (isNaN($("#values").val())){
            alert("压差报警值必须为数值类型")
            return false
        }else if ($("#time").val().trim()==" "){
            alert("时间不能为空")
            return
        }else if (!timi.test($("#time").val())){
            alert("时间格式不正确")
            return false
        }
        $("form").submit();
    }
</script>
</html>
